/* Copyright (c) 2003-2020 by Kithara Software GmbH. All rights reserved. */

//##############################################################################################################
//
// File:        _KitharaSmp.h
//
// Description: Declaration of convenience functions for C++ samples
//
// Creator:     u.jes 2003-01-08
//
//##############################################################################################################

   /*=====================================================================*\
   |                    *** DISCLAIMER OF WARRANTY ***                     |
   |                                                                       |
   |       THIS  CODE AND INFORMATION IS PROVIDED "AS IS"  WITHOUT         |
   |       A  WARRANTY OF  ANY KIND, EITHER  EXPRESSED OR  IMPLIED,        |
   |       INCLUDING  BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF         |
   |       MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.        |
   \*=====================================================================*/

//##############################################################################################################
//
// Purpose:
// The functions declared in this file are convenience functions used by the samples.
// They provide an input/output layer, abstracting the different supported programming languages and
// environments.
//
//##############################################################################################################

#ifndef ___KitharaSmp_H
#define ___KitharaSmp_H


//--------------------------------------------------------------------------------------------------------------
// _KitharaSmp
//--------------------------------------------------------------------------------------------------------------

#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif

#pragma pack(push, 8)
#include <stdio.h>
#include <conio.h>
#include <string.h>
#pragma pack(pop)

#include "LinkControl.h"

#if defined(_MSC_VER) && _MSC_VER <= 1200
#define for if (0) {} else for
#endif

#ifdef _MSC_VER
inline int myGetch() { return _getch(); }
inline void myPutch(int ch) { _putch(ch); }
inline int myStricmp(const char *s1, const char *s2) { return _stricmp(s1, s2); }
inline int myKbhit() { return _kbhit(); }
#else
inline int myGetch() { return getch(); }
inline void myPutch(int ch) { putch(ch); }
inline int myStricmp(const char *s1, const char *s2) { return stricmp(s1, s2); }
inline int myKbhit() { return kbhit(); }
#endif

void outputTxt(const char* pText, bool line = true);
void outputBool(int value, const char* pPreTxt = "", const char* pPostTxt = "", bool line = true);
void outputDec(int64 value, const char* pPreText = "", const char* pPostText = "", bool line = true);
void outputFloat(double value, const char* pPreText = "", const char* pPostText = "", bool line = true);
void outputHex02(byte value, const char* pPreTxt = "", const char* pPostTxt = "", bool line = true);
void outputHex04(ushort value, const char* pPreTxt = "", const char* pPostTxt = "", bool line = true);
void outputHex08(uint value, const char* pPreTxt = "", const char* pPostTxt = "", bool line = true);
void outputHex16(uint64 value, const char* pPreTxt = "", const char* pPostTxt = "", bool line = true);
void outputIpv4(uint ip, const char* pPreTxt = "", const char* pPostTxt = "", bool line = true);
void outputErr(KSError error, const char* pFuncName, const char* pComment = "");
char* inputTxt(const char* pPreText = "", const char* pDefault = "");
int inputDec(const char* pPreText = "", const char* pDefault = "");
int inputDec(const char* pPreText, int defaultVal);
int64 inputDec64(const char* pPreText, const char* pDefault = "");
int64 inputDec64(const char* pPreText, int64 defaultVal);
int inputHex(const char* pPreText = "", const char* pDefault = "");
int inputHex(const char* pPreText, int defaultVal);
void waitTime(uint time);
#endif // ___KitharaSmp_H
